import request from '@/config/axios'

// 工位 VO
export interface WorkstationVO {
  id: number // 主键
  workstationIndex: string // 工位序号
  workstationName: string // 工位名称
  department: number // 部门
  processOrder: number // 工艺顺序
  business: string // 工位业务
  isControl: boolean // 是否控制
  remark: string // 备注
  electronicScaleId: number // 电子秤 ID
  electronicScaleName: string // 电子秤
  userId: number // 用户ID
  username: string // 用户名称
}

// 工位 API
export const WorkstationApi = {
  // 查询工位分页
  getWorkstationPage: async (params: any) => {
    return await request.get({ url: `/project/workstation/page`, params })
  },

  // 查询工位详情
  getWorkstation: async (id: number) => {
    return await request.get({ url: `/project/workstation/get?id=` + id })
  },

  // 新增工位
  createWorkstation: async (data: WorkstationVO) => {
    return await request.post({ url: `/project/workstation/create`, data })
  },

  // 修改工位
  updateWorkstation: async (data: WorkstationVO) => {
    return await request.put({ url: `/project/workstation/update`, data })
  },

  // 删除工位
  deleteWorkstation: async (id: number) => {
    return await request.delete({ url: `/project/workstation/delete?id=` + id })
  },

  // 导出工位 Excel
  exportWorkstation: async (params) => {
    return await request.download({ url: `/project/workstation/export-excel`, params })
  },

  checkAndCompletePlan: async (orderCode: string) => {
    return await request.get({ url: `/project/internal-workstation-plan/checkAndCompletePlan?orderCode=` + orderCode })
  },
}
